<template>
  <view class="my-userInfo">
    <!-- 头部区域 -->
    <view class="head">
      <image :src="userInfo.avatarUrl" mode=""></image>
      <text>{{ userInfo.nickName }}</text>
    </view>
    <!-- 收藏区域 -->
    <!-- 收藏区域 -->
    <view class="one">
      <view class="item" v-for="item in 4" :key="item">
        <text>8</text>
        <text>收藏的店铺</text>
      </view>
    </view>
    <!-- 订单区域 -->
    <!-- 订单区域 -->
    <view class="two">
      <view class="title">
        我的订单
      </view>
      <view class="box">
        <view class="item" v-for="item in 4" :key="item">
          <image src="../../static/my-icons/icon2.png" mode=""></image>
          <text>待付款</text>
        </view>
      </view>
    </view>
    <!-- 收货地址 -->
    <view class="three">
      <view class="item">
        <view class="left">
          收货地址
        </view>
        <view class="right">
          <uni-icons type="right"></uni-icons>
        </view>
      </view>
      <view class="item">
        <view class="left">
          联系客服
        </view>
        <view class="right">
          <uni-icons type="right"></uni-icons>
        </view>
      </view>
      <view class="item" @click="exit">
        <view class="left">
          退出登录
        </view>
        <view class="right">
          <uni-icons type="right"></uni-icons>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    mapState
  } from 'vuex'
  export default {
    name: "my-userInfo",
    computed: {
      ...mapState('user', ['userInfo'])
    },
    data() {
      return {

      };
    },
    methods: {
      // 退出登录
      async exit() {
        // 确定框
        const res = await uni.showModal({
          title: "温馨提示",
          content: "您确定退出该网站吗?"
        })
        if (res.confirm) {
          // 清除token与用户信息
          this.$store.commit('user/logout')
        }

      }
    }
  }
</script>

<style lang="scss" scoped>
  .my-userInfo {
    .head {
      height: 400rpx;
      background-color: #c00000;
      color: #fff;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;

      image {
        border-radius: 50%;
        border: 2px solid #fff;
        width: 160rpx;
        height: 160rpx;
        margin-bottom: 20rpx;
      }
    }
  }

  .my-userInfo {
    background-color: #f4f4f4;
    height: 100vh;

    .head {
      height: 400rpx;
      background-color: #c00000;
      color: #fff;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;

      image {
        border-radius: 50%;
        border: 2px solid #fff;
        width: 160rpx;
        height: 160rpx;
        margin-bottom: 20rpx;
      }
    }

    .one {
      display: flex;
      background-color: #fff;
      margin: 0 40rpx;
      font-size: 12px;
      border-radius: 10rpx;
      margin-top: -20rpx;

      .item {
        padding: 20rpx 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
      }
    }
  }

  .two {
    background-color: #fff;
    margin: 20rpx 40rpx;
    border-radius: 10rpx;

    .title {
      line-height: 80rpx;
      border-bottom: 1px solid #f4f4f4;
      font-size: 14px;
      padding-left: 20rpx;
    }

    .box {
      display: flex;

      .item {
        padding: 10rpx 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 12px;

        image {
          width: 80rpx;
          height: 80rpx;
        }
      }
    }
  }

  .three {
    background-color: #fff;
    margin: 0rpx 40rpx;
    border-radius: 10rpx;
    font-size: 14px;

    .item {
      display: flex;
      justify-content: space-between;
      padding: 20rpx;
    }
  }
</style>